<template>
    <div class="index-lists">
        <el-card class="!border-none" shadow="never">
            <el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
                <el-form-item label="用户编号" prop="uid">
                    <el-input class="w-[280px]" v-model="queryParams.uid" />
                </el-form-item>
                <el-form-item label="短剧编号" prop="drama_id">
                    <el-input class="w-[280px]" v-model="queryParams.drama_id" />
                </el-form-item>
                <el-form-item label="剧集编号" prop="series_id">
                    <el-input class="w-[280px]" v-model="queryParams.series_id" />
                </el-form-item>
                <el-form-item label="开始观看时间" prop="start_time">
                    <daterange-picker
                        v-model:startTime="queryParams.start_start_time"
                        v-model:endTime="queryParams.start_end_time"
                    />
                </el-form-item>
                <el-form-item label="上次观看时间" prop="start_time">
                    <daterange-picker
                        v-model:startTime="queryParams.last_start_time"
                        v-model:endTime="queryParams.last_end_time"
                    />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="resetPage">查询</el-button>
                    <el-button @click="resetParams">重置</el-button>
                </el-form-item>
            </el-form>
        </el-card>
        <el-card class="!border-none mt-4" shadow="never">
            <el-table
                class="mt-4"
                size="large"
                v-loading="pager.loading"
                :data="pager.lists"
            >
                <el-table-column label="用户uid" prop="uid" min-width="60" />
                <el-table-column label="短剧编号" prop="drama_id" min-width="60" />
                <el-table-column label="短剧名称" show-overflow-tooltip prop="drama_title" min-width="80" />
                <el-table-column label="剧集编号" prop="series_id" min-width="80" />
                <el-table-column label="消耗币" prop="money" min-width="60" />
                <el-table-column label="上次阅读时间" prop="last_time" min-width="110" />
                <el-table-column label="开始阅读时间" prop="start_time" min-width="110" />
                <el-table-column label="用户注册时间" prop="user_create_time" min-width="110" />
                <el-table-column label="创建时间" prop="create_time" min-width="110" />
<!--                <el-table-column label="更新时间" prop="update_time" min-width="110" />-->
            </el-table>
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
    </div>
</template>
<script lang="ts" setup name="records">
import { recordsLists } from '@/api/client/read_records'
import { usePaging } from '@/hooks/usePaging'
const { query } = useRoute()
const queryParams = reactive({
    uid: Number(query.uid),
    series_id: '',
    drama_id: '',
    last_time: '', // 上次阅读时间
    start_start_time: '',
    start_end_time: '',
    last_start_time: '',
    last_end_time: '',
})

const { pager, getLists, resetPage, resetParams } = usePaging({
    fetchFun: recordsLists,
    params: queryParams
})

getLists()
</script>
